import i18n, { t } from '@src/locales';
import TaskStateEnum from "@model/enum/TaskStateEnum";

// 列表 && 选择列
export const getColumnFields = () => {
  return [
    {
      fieldName: 'sparepartNo',
      displayName:  t('part.occupy.sparepartNo'), // 备件编号
      formType: 'text',
      isSearch: 1,
    },
    {
      fieldName: 'sparepartName',
      displayName: t('part.occupy.sparepartName'), // 备件名称
      formType: 'text',
      isSearch: 1,
    },
    {
      fieldName: 'claimant',
      displayName:  t('part.occupy.claimant'), // 申领人
      formType: 'user',
      isSearch: 1,
    },
    {
      fieldName: 'taskNo',
      displayName: t('part.occupy.taskNo'), // 工单编号
      formType: 'text',
      isSearch: 1,
    },
    {
      fieldName: 'taskState',
      displayName: t('part.occupy.taskState'), // 工单状态
      formType: 'select',
      isSearch: 1,
      setting: {
        isMulti: true,
        dataSource:[
          { text: i18n.t('common.task.type.created'), value: TaskStateEnum.CREATED.value, },
          { text: i18n.t('common.task.type.allocated'), value: TaskStateEnum.ALLOCATED.value, },
          { text: i18n.t('common.task.type.accepted'), value: TaskStateEnum.ACCEPTED.value, },
          { text: i18n.t('common.task.type.processing'), value: TaskStateEnum.PROCESSING.value, },
          { text: i18n.t('common.task.type.finished'), value: TaskStateEnum.FINISHED.value, },
          { text: i18n.t('common.task.type.refused'), value: TaskStateEnum.REFUSED.value, },
          { text: i18n.t('common.task.type.costed'), value: TaskStateEnum.COSTED.value, },
          { text: i18n.t('common.task.type.closed'), value: TaskStateEnum.CLOSED.value, },
          { text: i18n.t('common.task.type.offed'), value: TaskStateEnum.OFFED.value, },
          { text: i18n.t('common.task.type.taskPool'), value: TaskStateEnum.TASK_POOL.value, },
        ],
      }
    },
    {
      fieldName: 'applyRemark',
      displayName: t('part.occupy.applyRemark'), // 申领备注
      formType: 'text',
      isSearch: 1,
    },
    {
      fieldName: 'returnRemark',
      displayName: t('part.occupy.returnRemark'), // 返还备注
      formType: 'text',
      isSearch: 1,
    },
    {
      fieldName: 'applyNum',
      displayName: t('part.occupy.applyNum'), // 申领数量
      formType: 'number',
      isSearch: 1,
    },
    {
      fieldName: 'waitUsedNum',
      displayName: t('part.occupy.waitUsedNum'), // 待使用
      formType: 'number',
      isSearch: 1,
    },
    {
      fieldName: 'usedNum',
      displayName: t('part.occupy.usedNum'), // 已使用
      formType: 'number',
      isSearch: 1,
    },
    {
      fieldName: 'unUsedNum',
      displayName: t('part.occupy.unUsedNum'), // 未使用
      formType: 'number',
      isSearch: 1,
    },
    {
      fieldName: 'needReturnNum',
      displayName: t('part.occupy.needReturnNum'), // 需返还
      formType: 'number',
      isSearch: 1,
    },
    {
      fieldName: 'returnedNum',
      displayName: t('part.occupy.returnedNum'), // 已返还
      formType: 'text',
      isSearch: 1,
    },
    /*{
      fieldName: 'courierNumber',
      displayName: t('part.occupy.courierNumber'),
      formType: 'text',
      isSearch: 1,
    },
    {
      fieldName: 'sparepartOrderType',
      displayName: t('part.occupy.sparepartOrderType'),
      formType: 'text',
      isSearch: 1,
    },*/
    {
      fieldName: 'customerName',
      displayName: t('part.occupy.customerName'), // 客户名称
      formType: 'text',
      isSearch: 1,
    },
    {
      fieldName: 'equipmentSerialNumber',
      displayName: t('part.occupy.equipmentSerialNumber'), // 设备序列号
      formType: 'text',
      isSearch: 1,
    },
    {
      fieldName: 'productModel',
      displayName: t('part.occupy.productModel'), // 产品型号
      formType: 'text',
      isSearch: 1,
    },
    {
      fieldName: 'warrantyStatus',
      displayName: t('part.occupy.warrantyStatus'), // 质保状态
      formType: 'select',
      isSearch: 1,
      setting: {
        dataSource:['保内', '保外'],
      }
    },
    {
      fieldName: 'equipmentInstallationTime',
      displayName: t('part.occupy.equipmentInstallationTime'), // 设备验收时间
      formType: 'date',
      isSearch: 1,
    },
    {
      fieldName: 'repairman',
      displayName: t('part.occupy.repairman'), // 报修人
      formType: 'text',
      isSearch: 1,
    },
    {
      fieldName: 'dispatchOrderType',
      displayName: t('part.occupy.dispatchOrderType'), // 派工单类型
      formType: 'text',
      isSearch: 1,
    },
    {
      fieldName: 'repairContent',
      displayName: t('part.occupy.repairContent'), // 报修内容
      formType: 'text',
      isSearch: 1,
    },
    {
      fieldName: 'serviceTag',
      displayName: t('part.occupy.serviceTag'), // 服务部门
      formType: 'tags',
      isSearch: 1,
    },
    {
      fieldName: 'engineerArea',
      displayName: t('part.occupy.engineerArea'), // 工程师区域
      formType: 'text',
      isSearch: 1,
    },
    {
      fieldName: 'executor',
      displayName: t('part.occupy.executor'), // 负责人
      formType: 'user',
      isSearch: 1,
    },
    {
      fieldName: 'serviceContentText',
      displayName: t('part.occupy.serviceContent'), // 服务内容
      formType: 'text',
      isSearch: 1,
    },
    {
      fieldName: 'faultCode',
      displayName: t('part.occupy.faultCode'), // 故障代码
      formType: 'text',
      isSearch: 1,
    },
    {
      fieldName: 'taskCloseTime',
      displayName: t('part.occupy.taskCloseTime'), // 关单时间
      formType: 'datetime',
      isSearch: 1,
    },
    {
      fieldName: 'sparepartApplyTime',
      displayName: t('part.occupy.sparepartApplyTime'), // 备件申请时间
      formType: 'datetime',
      isSearch: 1,
    },
    {
      fieldName: 'sparepartReturnTime',
      displayName: t('part.occupy.sparepartReturnTime'), // 备件返还时间
      formType: 'datetime',
      isSearch: 1,
    },
  ].map(item => {
    // 初始化属性
    return {
      ...item,
      setting: item.setting || {},
      isSystem: 1,
      isNull: 1,
      orderId: 1,
      show: true,
      tableName: 'partOccupy',
      minWidth: 150,
      visable: true,
      field: item.fieldName
    };

  });
};